import java.lang.reflect.Array;
import java.util.*;

public class day230518 {
    // 简单错误记录
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> listFile = new ArrayList<>();
        int[] count = new int[100];
        while (sc.hasNextLine()) {
            String str = sc.nextLine();
            // 取 '\' 后的 文件名 和 行数
            String fileName = fileName = str.substring(str.lastIndexOf('\\') + 1);

            // 文件名只取 16 个字符
            String[] ret = fileName.split(" ");
            if (ret[0].length() > 16) {
                ret[0] = ret[0].substring(ret[0].length() - 16);
            }
            fileName = ret[0] + " " + ret[1];

            // 查看有相同的文件名
            int index = listFile.indexOf(fileName);
            if (index == -1) {
                listFile.add(fileName);
                index = listFile.indexOf(fileName);
            }
            count[index]++;
        }
        int size = listFile.size();
        int index = 0;
        if (size > 8) {
            index = listFile.size() - 8;
        }
        for (int i = index; i < index + 8 && i < listFile.size(); i++) {
            System.out.println(listFile.get(i) + " " + count[i]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // HashMap 记录出错记录的出现次数
        HashMap<String, Integer> map = new HashMap<>();
        // 用顺序表记录, 出错记录的顺序
        ArrayList<String> arr = new ArrayList<>();
        while (sc.hasNext()) {
            // 文件名
            String curStr = sc.next();
            // 行号
            String line = sc.next();
            // 取 '\' 后的文件名
            curStr = curStr.substring(curStr.lastIndexOf("\\") + 1);

            // 文件名只取 16 个字符
            if (curStr.length() > 16) {
                curStr = curStr.substring(curStr.length() - 16);
            }

            curStr += " " + line;

            // 判断是否是第一次出现
            if (!map.containsKey(curStr)) {
                arr.add(curStr);
            }
            map.put(curStr, map.getOrDefault(curStr, 0) + 1);
        }

        int start = 0;
        if (map.size() > 8) {
            start = map.size() - 8;
        }
        for (; start < map.size(); ++start) {
            System.out.println(arr.get(start) + " " + map.get(arr.get(start)));
        }
    }
}
